import com.qian.api.ddj.util.SignUtils;
import com.yaowk.api.utils.HttpUtils;
import org.apache.commons.codec.digest.DigestUtils;
import org.junit.Test;

import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;

public class XJ {
//        private String KEY = "2fdc4b62676426a5f95eb58f9967d352";
//    private String USERID = "648418";
//    private String KEY = "5c2d6f8e4cf3a602b7b95966be775f98";
//    private String USERID = "085024";
    private String KEY = "670362e5ac601925cbb55efcaf0ac6f5";
    private String USERID = "187651";
    private String name = "关宇";
    private String city = "太原市";

    @Test
    public void pay() {
        Map<String, String> map = new TreeMap<>();
        map.put("userid", USERID);
        map.put("payType", "WXZF");
        map.put("subject", "测试");
        map.put("amount", "50");
        map.put("returnUrl", "http://extman.kefupay.cn/newWechats/test111.action");
        /**参与验签的字段*/
        String sign = SignUtils.params(map);
        System.out.println("计算签名的报文为：" + sign);
        sign = DigestUtils.md5Hex(sign + KEY);
        map.put("orderCode", "xj_codePay");
        map.put("sign", sign);
        map.put("pay_number", UUID.randomUUID().toString());
        map.put("notify_url", "http://extman.kefupay.cn/newWechats/test111.action");
        String baowen = HttpUtils.formatData(map);
        System.out.println("上送的报文为：" + baowen);
        String sr = HttpUtils.post("http://extman.kefupay.cn/pay/pay_mobile.action", baowen);
        System.out.println(sr);
    }

    @Test
    public void cash(){
        Map<String, String> map = new TreeMap<>();
        map.put("userid", USERID);
        map.put("accountno", "6214834316073171");
        map.put("accountName", "关宇");
        map.put("amount", "2300");
        map.put("city", "太原市");
        /**参与验签的字段*/
        String sign = SignUtils.params(map);
        System.out.println("计算签名的报文为：" + sign);
        sign = DigestUtils.md5Hex(sign + KEY);
        map.put("orderCode", "xj_codeWithdraw");
        map.put("sign", sign);
        map.put("pay_number", String.valueOf(System.currentTimeMillis()));
        map.put("notify_url", "http://extman.kefupay.cn/newWechats/test111.action");
        String baowen = HttpUtils.formatData(map);
        System.out.println("上送的报文为：" + baowen);
        String sr = HttpUtils.post("http://extman.kefupay.cn/pay/pay_mobile.action", baowen);
        System.out.println(sr);
    }

    @Test
    public void userQuery(){
        Map<String, String> map = new TreeMap<>();
        map.put("userid", USERID);
        String sign = SignUtils.params(map);
        System.out.println("计算签名的报文为：" + sign);
        sign = DigestUtils.md5Hex(sign + KEY);
        map.put("orderCode", "xj_userQuery");
        map.put("sign", sign);
        String baowen = HttpUtils.formatData(map);
        System.out.println("上送的报文为：" + baowen);
        String sr = HttpUtils.post("http://extman.kefupay.cn/pay/pay_mobile.action", baowen);
        System.out.println(sr);
    }

    @Test
    public void query(){
        Map<String, String> map = new TreeMap<>();
        map.put("userid", USERID);
        String sign = SignUtils.params(map);
        System.out.println("计算签名的报文为：" + sign);
        sign = DigestUtils.md5Hex(sign + KEY);
        map.put("orderCode", "xj_codeQuery");
        map.put("sign", sign);
        map.put("pay_number", "3020171019000134189274");
        String baowen = HttpUtils.formatData(map);
        System.out.println("上送的报文为：" + baowen);
        String sr = HttpUtils.post("http://extman.kefupay.cn/pay/pay_mobile.action", baowen);
        System.out.println(sr);
    }
    @Test
    public void wg(){
        Map<String, String> map = new TreeMap<>();
        map.put("userid", USERID);
        map.put("accountno", "6214834316073171");
        map.put("accountName", name);
        map.put("amount", "10");
        map.put("city", city);
        /**参与验签的字段*/
        String sign = SignUtils.params(map);
        sign = DigestUtils.md5Hex(sign + KEY);
        map.put("orderCode", "xj_codeWithdraw");
        map.put("sign", sign);
        map.put("pay_number","3020171019000134189272");
        map.put("notify_url", "http://extman.kefupay.cn/newWechats/test111.action");
        String baowen = HttpUtils.formatData(map);
        System.out.println("上送的报文为：" + baowen);
        String sr = HttpUtils.post("http://extman.kefupay.cn/pay/pay_mobile.action", baowen);
        System.out.println(sr);
    }
}
